Skip to content

fix: open detail page when clicking edit for time-off policies#1690

Merged
jeffredodd merged 2 commits intomainfrom
fix/non-holiday-policy-guard
May 6, 2026
Merged

fix: open detail page when clicking edit for time-off policies#1690
jeffredodd merged 2 commits intomainfrom
fix/non-holiday-policy-guard

Conversation

@jeffredodd
Copy link
Copy Markdown
Contributor

@jeffredodd jeffredodd commented May 6, 2026

Summary

Fixes two issues that surfaced when a company has time-off policies outside the supported sick / vacation (PTO) / holiday set — for example, legacy custom, bereavement, or parental_leave policies migrated from Gusto.com:

  1. Edit Policy did nothing. The state machine's TIME_OFF_VIEW_POLICY transition guarded on policyType === 'sick' || 'vacation', so any other type matched no guard and the event was swallowed. Renames the guard to isNonHolidayView (returns policyType !== 'holiday') so any non-holiday policy routes to viewTimeOffPolicyDetail. Broadens TimeOffPolicyType to PolicyType | 'holiday' and narrows it back at the create-policy selector (which still only offers sick/vacation/holiday).
  2. Detail screen exposed edit actions for unsupported types. Adds a shared isEditableTimeOffPolicyType guard ('sick' | 'vacation' | 'holiday') used on the policy list and detail screens. Non-editable policies render in view-only mode: the kebab shows "View policy" instead of edit/delete, the detail page hides Add Employee / Edit Policy / Change Settings, and per-employee balance edit and removal are suppressed.

Also simplifies the holiday pay policy throwOnError to () => false since it's auxiliary to the main list and any failure is surfaced inline via composeErrorHandler.

Test plan

  • npm run test -- --run src/components/UNSTABLE_TimeOff/TimeOffFlow/timeOffStateMachine.test.ts — 51/51 passing
  • npx tsc --noEmit — clean
  • Manual: with a non-sick/vacation policy (e.g. custom) attached to the company, the policy list kebab shows "View policy" only; opening it shows the detail screen with no edit/add/remove affordances and no balance-edit menu items.

🤖 Generated with Claude Code

@jeffredodd jeffredodd force-pushed the fix/non-holiday-policy-guard branch from 5a332f0 to 4f26526 Compare May 6, 2026 02:36
@jeffredodd jeffredodd marked this pull request as ready for review May 6, 2026 02:45
Copilot AI review requested due to automatic review settings May 6, 2026 02:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes TimeOffFlow navigation so TIME_OFF_VIEW_POLICY correctly opens the policy detail screen for any non-holiday time-off policy type (e.g., custom, bereavement, parental_leave, etc.), instead of being silently ignored due to overly narrow guards/types.

Changes:

  • Updated the TIME_OFF_VIEW_POLICY guard to route all non-holiday policy types to viewTimeOffPolicyDetail.
  • Broadened TimeOffPolicyType to accept the full API PolicyType union (plus 'holiday') so flow context/payloads can represent migrated policy types.
  • Added parameterized state-machine tests covering several non-holiday policy types and updated the policy-type selector defaulting to only preselect sick/vacation/holiday.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/components/UNSTABLE_TimeOff/TimeOffFlow/timeOffStateMachine.ts Broadens view-policy payload typing and updates the view-policy guard to route all non-holiday policies to the standard detail state.
src/components/UNSTABLE_TimeOff/TimeOffFlow/timeOffStateMachine.test.ts Adds coverage to ensure non-holiday (non sick/vacation) policy types transition to viewTimeOffPolicyDetail.
src/components/UNSTABLE_TimeOff/TimeOffFlow/timeOffPolicyTypes.ts Expands TimeOffPolicyType to include all API policy types, enabling flow context to hold migrated values.
src/components/UNSTABLE_TimeOff/TimeOffFlow/TimeOffFlowComponents.tsx Prevents invalid defaults in the create-policy selector by only defaulting when policyType is one of sick/vacation/holiday.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeffredodd jeffredodd changed the title fix: open detail page for non-sick/vacation time-off policies fix: open detail page when clicking edit for time-off policies May 6, 2026
The TIME_OFF_VIEW_POLICY transition guarded on
policyType === 'sick' || 'vacation', but the API's PolicyType union
includes bereavement, custom, floating_holiday, jury_duty,
learning_and_development, parental_leave, personal_day, volunteer, and
weather. Companies migrated from Gusto.com may have any of these
attached to their account. For any non-sick/vacation/holiday type the
event matched no guard, the state machine swallowed it, and clicking
"Edit policy" in the kabob menu appeared to do nothing.

Rename the guard to isNonHolidayView (returns policyType !== 'holiday')
so any non-holiday policy routes to viewTimeOffPolicyDetail. Broaden
TimeOffPolicyType to PolicyType | 'holiday' so the context can hold the
broader values, and narrow back at the create-policy selector site.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Restrict edit/add/remove affordances on the policy list and detail
screens to sick, vacation, and holiday policies via a shared
isEditableTimeOffPolicyType guard. Other policy types (bereavement,
custom, parental_leave, etc.) render in view-only mode: the kebab shows
"View policy" instead of edit/delete, the detail page hides the add
employee, edit policy, and change settings actions, and per-employee
balance edit / removal controls are suppressed.

Also simplify the holiday pay policy throwOnError to never throw, since
it's auxiliary to the main list and any failure is surfaced inline via
composeErrorHandler.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeffredodd jeffredodd force-pushed the fix/non-holiday-policy-guard branch from 4f26526 to 798438e Compare May 6, 2026 18:15
@jeffredodd jeffredodd enabled auto-merge (squash) May 6, 2026 18:15
@jeffredodd jeffredodd merged commit c8d9430 into main May 6, 2026
20 checks passed
@jeffredodd jeffredodd deleted the fix/non-holiday-policy-guard branch May 6, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants